package global

// Configuration config from conf/config.dev.yml
type Configuration struct {
	System SystemConfiguration `mapstructure:"system" json:"system"`
	Mysql  MysqlConfiguration  `mapstructure:"mysql" json:"mysql"`
	Redis  RedisConfiguration  `mapstructure:"redis" json:"redis"`
	Jwt    JwtConfiguration    `mapstructure:"jwt" json:"jwt"`
	WeChat WeChatConfiguration `mapstructure:"we-chat" json:"weChat"`
	MQTT   MqttConfiguration   `mapstructure:"mqtt" json:"mqtt"`
}

type MqttConfiguration struct {
	Broker   string `mapstructure:"broker" json:"broker" yaml:"Broker"`
	Port     int64  `mapstructure:"port" json:"port"`
	ClientID string `mapstructure:"client-id" json:"clientId" yaml:"ClientID"`
	Topic    string `mapstructure:"topic" json:"topic" `
	Username string `mapstructure:"username" json:"username" yaml:"Username"`
	Password string `mapstructure:"password" json:"password" yaml:"Password"`
}

type SystemConfiguration struct {
	Base                 string `mapstructure:"-" json:"-"`
	Domain               string `mapstructure:"domain" json:"domain"`
	UrlPrefix            string `mapstructure:"url-prefix" json:"urlPrefix"`
	ApiVersion           string `mapstructure:"api-version" json:"apiVersion"`
	Port                 int    `mapstructure:"port" json:"port"`
	IdempotenceTokenName string `mapstructure:"idempotence-token-name" json:"idempotenceTokenName"`
	Debug                bool   `mapstructure:"debug" json:"debug"`
}

type MysqlConfiguration struct {
	Uri         string `mapstructure:"uri" json:"uri"`
	TablePrefix string `mapstructure:"table-prefix" json:"tablePrefix"`
	PrintSql    bool   `mapstructure:"print-sql" json:"printSql"`
	Transaction bool   `mapstructure:"transaction" json:"transaction"`
	InitData    bool   `mapstructure:"init-data" json:"initData"`
}

type RedisConfiguration struct {
	Host     string `mapstructure:"host" json:"host"`
	Username string `mapstructure:"username" json:"username"`
	Password string `mapstructure:"password" json:"password"`
	DB       int    `mapstructure:"db" json:"db"`
}

type JwtConfiguration struct {
	Key        string `mapstructure:"key" json:"key"`
	Timeout    int    `mapstructure:"timeout" json:"timeout"`
	MaxRefresh int    `mapstructure:"max-refresh" json:"maxRefresh"`
}

type WeChatConfiguration struct {
	Official WeChatOfficialConfiguration `mapstructure:"official" json:"official"`
}

type WeChatOfficialConfiguration struct {
	AppId              string                                        `mapstructure:"app-id" json:"appId"`
	AppSecret          string                                        `mapstructure:"app-secret" json:"appSecret"`
	Encoding           string                                        `mapstructure:"encoding" json:"encoding"`
	TplMessageCronTask WeChatOfficialTplMessageCronTaskConfiguration `mapstructure:"tpl-message-cron-task" json:"tplMessageCronTask"`
}

type WeChatOfficialTplMessageCronTaskConfiguration struct {
	Expr                string `mapstructure:"expr" json:"expr"`
	Users               string `mapstructure:"users" json:"users"`
	TemplateId          string `mapstructure:"template-id" json:"templateId"`
	MiniProgramAppId    string `mapstructure:"mini-program-app-id" json:"miniProgramAppId"`
	MiniProgramPagePath string `mapstructure:"mini-program-page-path" json:"miniProgramPagePath"`
}

type LogsConfiguration struct {
	Level string `mapstructure:"level" json:"level"`
}
